package com.zhiche.lisa.bms.service.fee.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zhiche.lisa.bms.dao.mapper.fee.FeePayableTempMapper;
import com.zhiche.lisa.bms.dao.model.fee.FeePayableTemp;
import com.zhiche.lisa.bms.service.fee.FeePayableService;
import com.zhiche.lisa.bms.service.fee.FeePayableTempService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 应付账款中间表 服务实现类
 * </p>
 *
 * @author linbao
 * @since 2019-01-23
 */
@Service
@Slf4j
public class FeePayableTempServiceImpl extends ServiceImpl<FeePayableTempMapper, FeePayableTemp> implements FeePayableTempService {

    @Autowired
    private FeePayableService feePayableService;

    private final Page<FeePayableTemp> page;

    private final EntityWrapper<FeePayableTemp> ew;

    {
        page = new Page<>();
        page.setCurrent(1);
        page.setSize(100);

        ew = new EntityWrapper<>();
        ew.eq("status", 0);
        // ew.ne("trans_type_id", 0);
        ew.orderBy("id asc");
    }

    /**
     * 获取数据
     *
     * @return
     */
    @Override
    @Transactional(noRollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public List<FeePayableTemp> getFeeTempList() {
        Page<FeePayableTemp> feePayableTempPage = this.selectPage(page, ew);
        if (feePayableTempPage != null && CollectionUtils.isNotEmpty(feePayableTempPage.getRecords())) {
            return feePayableTempPage.getRecords();
        }
        return null;
    }
}
